#include <string.h>
#include <iostream>
using std::cout;
using std::endl;

void test0(){
    char arr[6] = {'h','e','l','l','o','\0'};
    char arr2[] = {'h','e','l','l','o'};//没有终止符
    char arr3[6] = {'h','e','l','l','o'};
    cout << arr2 << endl;

    char arr4[6] = "hello";
    arr4[0] = 'H';
    cout << arr4 << endl;


    /* char * pstr = "world"; */
    /* pstr[0] = 'W'; */
    const char * pstr = "world";
    cout << pstr << endl;

    char * p = new char[strlen(pstr) + 1]();
    strcpy(p,pstr);
    p[0] = 'W';
    cout << p << endl;

    //const char * 只能在初始化时赋初值，初始化之后不能修改内容
    /* const char * p = new char[strlen(pstr) + 1]{'w','o','r','l','d'}; */
    /* p[0] = 'W'; */
}

int main(void){
    test0();
    return 0;
}
